package com.momo.momobackendquestionservice.controller.inner;

import com.momo.momobackendmodel.model.entity.Question;
import com.momo.momobackendmodel.model.entity.QuestionSubmit;
import com.momo.momobackendquestionservice.service.QuestionService;
import com.momo.momobackendquestionservice.service.QuestionSubmitService;
import com.momo.momobackendserviceclient.service.QuestionFeginClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 十三
 * @create 2024-04-05 14:52
 * @Description:
 */
@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeginClient {

    @Resource
    private QuestionService questionService;

    @Resource
    private QuestionSubmitService questionSubmitService;

    /**
     * 根据 Id 获取问题
     * @param questionId
     * @return
     */
    @Override
    @GetMapping("/get/id")
    public Question getQuestionById(@RequestParam("questionId") long questionId){
        return questionService.getById(questionId);
    }

    /**
     * 根据 Id 获取问题提交
     * @param questionSubmitId
     * @return
     */
    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId") long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    }

    /**
     * 更新问题提交
     * @param questionSubmit
     * @return
     */
    @Override
    @PostMapping("/question_submit/update")
    public boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    }
}
